|
|
|
|
|
|
|
Save and run the program. Now you must enter valid data in both fields before the form unloads. You have probably also found out that each time you click the OK button, all the form-level validation steps are performed. It is good programming practice to deliver all the validation results to the user at once. It can be very frustrating to fill out a form, receive an error message, and then fix the message, only to receive another one, and another one, and so on. |
|
|
|
|
|
|
|
|
Creating Your Own Validation Custom Control |
|
|
|
|
|
|
|
|
The input validation routines you created today cover most of the situations you are likely to encounter when designing data entry forms. In fact, after you design one or two of these forms, you begin to see that you are writing the same validation code over and over again. Instead of repeatedly writing the same code, or even constantly performing cut, copy, and paste operations, Microsoft Visual Basic 5 gives you the power to create your own custom controls that have new properties and methods for input validation. Once you build these new controls, they can be used in all your data entry programs. |
|
|
|
|
|
|
|
|
Creating a Custom Control |
|
|
|
|
|
|
|
|
In this section you get a crash course on creating custom controls using Visual Basic 5. |
|
|
|
|
| |
|
|
|
|
There are a lot of possibilities and considerations when creating custom controls. In this section, you get only the basics. You can find excellent examples of how to create your own custom controls and associated property pages in the Visual Basic 5 online documentation. Look up ''Controls" in the Online Books Index to see a list of topics related to using Visual Basic 5 to create custom controls. |
|
|
|
|
|
|
|
|
|
|
The first step in creating a custom control is to open a Visual Basic 5 UserControl code module. This module is a bit like the standard Visual Basic BAS (pronounced bass, like the fish) modules and like the Class modules introduced in Visual Basic 4. Using the UserControl module allows you to create properties, methods, and events for your custom control. Once you complete the control code, you can compile the object into an ActiveX control |
|
|
|
|
|